<?php
	include("includes/config.php");
	include("includes/db_class.php");
	include("includes/class_calendar.php");
	
	$cal = new Calendar;
	$db_const = new Db();

	$_SESSION['downloadprotect'] = md5($_SERVER['HTTP_USER_AGENT'] . $_SERVER['REMOTE_ADDR']);

	// This query function fatching Featured Register Online Sports Status Show form DB
	/*$table = "sports";
	$condition = "sport_status = 'Show'";
	$sort_field = "sport_name";
	$order_by = "DESC";
	$limit = "";

	$record_set = $db_const->record_set($table, $condition, $sort_field, $order_by, $limit, 'sport_id, sport_name');
	$reg_sport_array = $db_const->return_values($record_set['limit']);*/
	// End Query

	// This query function fatching Featured Gear Cornor Sports Status Show form DB
	/*$table = "sports";
	$condition = "sport_gear = 'Show'";
	$sort_field = "sport_name";
	$order_by = "DESC";
	$limit = "";

	$record_set = $db_const->record_set($table, $condition, $sort_field, $order_by, $limit, 'sport_id, sport_name');
	$gear_sport_array = $db_const->return_values($record_set['limit']);*/
	// End Query

	// This Qurey function for fetching Countries name form DB
	$table = "country";
	$condition = "";
	$sort_field = "";
	$order_by = "";
	$limit = "";

	$record_set =  $db_const->record_set($table, $condition, $sort_field, $order_by, $limit , '*', '', 'total');
	$country_array = $db_const->return_values($record_set['total']);
// Query is endeds

// This Qurey function for fetching States name form DB
	$table = "state";
	if($_POST['country_id']){
		$condition = "country_id = ".$_POST['country_id'];
	}else{
		$condition = "";
	}
	$sort_field = "";
	$order_by = "";
	$limit = "";

	$record_set =  $db_const->record_set($table, $condition, $sort_field, $order_by, $limit , '*', '', 'total');
	$state_array = $db_const->return_values($record_set['total']);
// Query is endeds

// This Qurey function for fetching Activities name form DB
	$table = "activity";
	$condition = "";
	$sort_field = "";
	$order_by = "";
	$limit = "";

	$record_set =  $db_const->record_set($table, $condition, $sort_field, $order_by, $limit , '*', '', 'total');
	$activity_array = $db_const->return_values($record_set['total']);
	// Query is endeds

// This query function fatching Adds form DB
	$table = "ads";
	$condition = "ads_location = 'Right'";
	$sort_field = "rand()";
	$order_by = "";
	$limit = "1";

	$record_set = $db_const->record_set($table, $condition, $sort_field, $order_by, $limit, 'ads_id, ads_type, ads_status');
	$ads_right_array = $db_const->return_values($record_set['limit']);
	// End Query

// This query function fatching Adds form DB
	$table = "ads";
	$condition = "ads_location = 'Bottom'";
	$sort_field = "rand()";
	$order_by = "";
	$limit = "1";

	$record_set = $db_const->record_set($table, $condition, $sort_field, $order_by, $limit, 'ads_id, ads_type, ads_status');
	$ads_bottom_array = $db_const->return_values($record_set['limit']);
	// End Query

// This Qurey function for fetching Description name form DB
	$table = "describe";
	$condition = "";
	$sort_field = "";
	$order_by = "";
	$limit = "";

	$record_set =  $db_const->record_set($table, $condition, $sort_field, $order_by, $limit , '*', '', 'total');
	$descp_array = $db_const->return_values($record_set['total']);
	// Query is endeds

	$error = "";
	$error1 = "";
	$error2 = "";
	$error3 = "";
	$error4 = "";
	$error5 = "";
	$error6 = "";
	$error7 = "";
	
	if(isset($_POST['user_registration_x'])){
		$fname = $_POST['fname'];
		$lname = $_POST['lname'];
		$email_address = $_POST['email_address'];
		$confirm_email = $_POST['confirm_email'];
		$password = $_POST['password'];
		$confirm_password = $_POST['confirm_password'];
		$disp_name = $_POST['display_name'];
		$country_id = $_POST['country_id'];
		$state_id = $_POST['state_id'];
		$zip_code = $_POST['zip_code'];
		$month = $_POST['month'];
		$day = $_POST['day'];
		$year = $_POST['year'];
		$sex = $_POST['sex'];
		$activity = $_POST['activity'];
		$describe = $_POST['describe'];
		$code = trim($_POST['code']);
		$date_of_birth = $_POST['year']."-".$_POST['month']."-".$_POST['day'];
		$user_pic = $_FILES['user_pic']['name'];
		
		// This is checking user email and user dispaly name function form DB
		$sql = mysql_query("SELECT user_email FROM em_user WHERE user_email = '$email_address'");
		$email_error = mysql_fetch_array($sql);
		
		$sql = mysql_query("SELECT user_display_name FROM em_user WHERE user_display_name = '$disp_name'");
		$name_error = mysql_fetch_array($sql);
		
			$check_counter = 0;
			if($code != $_SESSION['sess_captcha']){
				$error = "Please Enter Exact Code Showing In Image.";
				$check_counter =+ 1;
			}else if($sex[0] == NULL){
				$error1 = "Please choose one of your Gender.";
				$check_counter =+ 1;
			}else if($activity == NULL){
				$error2 = "Please check any one from Activity list.";
				$check_counter =+ 1;
			}else if($describe == NULL){
				$error3 = "Please check any one from Describe Yourself list.";
				$check_counter =+ 1;
			}else if($email_error == TRUE){
				$error4 = "This Email Address is already found in Database.";
				$check_counter =+ 1;
			}else if($name_error == TRUE){
				$error5 = "This Display Name already is already found in Database.";
				$check_counter =+ 1;
			}else if($password != $confirm_password){
				$error6 = "Your providing passwords are not matching.";
				$check_counter =+ 1;
			}else if($email_address != $confirm_email){
				$error7 = "Your providing email addresses are not matching.";
				$check_counter =+ 1;
			}

			if($_POST['newsletter'] == NULL){
				$newsletter_value = "no";
			}else{
				$newsletter_value = "yes";
			}
			// This for breaking implode($activity) error
			if(isset($activity)){
				$active = implode(",", $activity);
			}
			if(isset($describe)){
				$desc = implode(",", $describe);
			}
			if($user_pic != ""){
				$tmp_pic = $_FILES['user_pic']['tmp_name'];
				$pic_name = time()."_".$user_pic;
				$path = "pictures/".$pic_name;
				move_uploaded_file($tmp_pic, $path);
			}
// This Query Function Is Adding User in DB
		if($check_counter == 0){
			$add_user_array = array();
			$add_user_array['user_fname'] = $fname;
			$add_user_array['user_lname'] = $lname;
			$add_user_array['user_email'] = $email_address;
			$add_user_array['user_password'] = $password;
			$add_user_array['user_sex'] = $sex[0];
			$add_user_array['user_dob'] = $date_of_birth;
			$add_user_array['user_display_name'] = $disp_name;
			$add_user_array['user_country_id'] = $country_id;
			$add_user_array['user_state_id'] = $state_id;
			$add_user_array['user_zip_code'] = $zip_code;
			$add_user_array['user_activity_id'] = $active;
			$add_user_array['user_discription_id'] = $desc;
			$add_user_array['user_newsletter'] = $newsletter_value;
			$add_user_array['user_about_me'] = "";
			$add_user_array['user_phone'] = "";
			$add_user_array['user_occupation'] = "";
			$add_user_array['user_city'] = "";
			$add_user_array['user_pic'] = $pic_name;
			$add_user_array['user_timestemp'] = time();

			$table = "user";
			$info = $add_user_array;
			$add_user = $db_const->add_record($table, $info);

			$current_user_id = mysql_insert_id();
			$act_link = PATH_WEB."active.php?id=".base64_encode($current_user_id)."&name=".base64_encode($disp_name);
			$messege = "<table width='570' border='0' cellspacing='0' cellpadding='0'>
			  <tr>
				<td width='570'><a href='".PATH_WEB."'><img src='".PATH_WEB."images/logo.gif' border='0' /></a></td>
			  </tr>
			  <tr>
				<td width='570'><p ><strong><font style='font-family:Trebuchet MS, Arial, Helvetica, sans-serif;
				font-size:20px;
				color: #ff4800;
				font-weight:bold;'>Dear ".$disp_name.".</font></strong></p>
			  <p ><font color='#000000' size='2'>We welcome you for becoming a part of <a href='".PATH_WEB."'>IrishFit.com</a> TEAM. <br /> Here is your login information.
			</font></p>
		  <table width='100%' border='0'>
		   <tr>
			 <td><font style='font-family:Trebuchet MS;
			font-size:12px;
			color: #000000;
			font-weight:bold;'>Login</font></td>
			 <td><font style='font-family:Trebuchet MS;
			font-size:12px;
			color: #000000;'>".$email_address."</font></td>
		   </tr>
		   <tr>
				 <td><font style='font-family:Trebuchet MS;
				font-size:12px;
				color: #000000;
				font-weight:bold;'>Password</font></td>
        		<td><font style='font-family:Trebuchet MS;
				font-size:12px;
				color: #000000;'>".$password."</font></td>
           </tr>
        	<tr>
        		 <td colspan='2'>To Activate your account please click on the following link. Otherwise you are not allowed to access the <a href='".PATH_WEB."index.php'>Irishfit.com</a></td>
			</tr>
			<tr>
				<td colspan='2'><a href=\"$act_link\">".$act_link."</a></td>
			</tr>
		  </table>
		  <p><font color='#000000' size='2'>......................................................................</font><br />
		  </p>
		</td>
		 </tr>
		</table>";
		$subject = $disp_name." Login Information";
		$username = "noreply@IrishFit.com";
		$headers  = 'MIME-Version: 1.0' . "\r\n";
		$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
		$headers .= 'From: '.$username.' <'.$username.'>' . "\r\n";
		$email = mail($email_address, $subject, $messege, $headers);

		header("Location: user_register_done.php");
		}

	}
	$_SESSION['sess_captcha'] = substr(str_shuffle("0123456789acdefghijkmopqrstuvwxy"), 0, 5);
?>

<html>
<head>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>User Registration ---- IrishFit.com</title>
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
.calendarHeader{
 	font-weight: bolder; color:#006633;
	background-color: #EAF4FF;
}
.calendarToday{
	background-color: #ED8BF3;
}
.calendar{
	background-color: #EAF4FF;
}
.link-nav{
	text-decoration:none;
	font-family:Geneva, Arial, Helvetica, sans-serif; color:#000000;
	font-size:large;
}
</style>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script src="js/ajax.js" language="javascript"></script>
<script src="js/form_validate.js" language="javascript"></script>
<script type="text/javascript">
function check(){
	if(document.getElementById("password").value != document.getElementById("confirm_password").value){
		alert("Your provided passwords are not matching.");
		document.getElementById("confirm_password").focus();
		return false;
	}
	if(document.getElementById("email_address").value != document.getElementById("confirm_email").value){
		alert("Provided email addresses are not matching.");
		document.getElementById("confirm_email").focus();
		return false;
	}
}
</script>
</head>
<body>
<table width="1004" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center" valign="top"><table width="963" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td align="left" valign="top" style="border-left:1px solid #B5B6B8;border-right:1px solid #B5B6B8"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td height="74" align="center" bgcolor="#EAF4FF"><table width="96%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td width="37%" align="left" valign="top"><a href="index.php"><img src="images/logo.gif" border="0" /></a></td>
                          <td width="63%" align="right"><form action="search_event.php" method="post" name="search_event"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                              <tr>
                                <td width="63%" align="right" class="search">Event Search:</td>
                                <td width="30%" align="right"><input type="text" name="search" class="input" /></td>
                                <td width="7%" align="right"><input type="image" src="images/go.gif" name="search_event" /></td>
                              </tr>
                          </table></form></td>
                        </tr>
                    </table></td>
                  </tr>
                  <tr>
                    <td height="31" align="center" background="images/menu-bg.gif"><table width="98%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td width="81%" align="left" class="menu"><a href="index.php">Home</a>|<a href="#">Equipment</a>|<a href="result.php">Results</a>|<a href="dir_org.php">Event Directors & Organizers</a></td>
                          <td width="19%" align="right"><table width="179" border="0" cellspacing="0" cellpadding="0">
                              <tr>
                                <td width="109" align="right" class="menu"><?php if(isset($_SESSION['type'])){ echo "<a href='main_page.php'>".$_SESSION['u_name']."</a>";}else{?><a href="login.php"><img src="images/login.gif" alt="" width="61" height="24" border="0" /></a><?php } ?></td>
                              	<td width="70" align="right" class="menu"><?php if(isset($_SESSION['type'])){ echo "<a href='logout.php'>Logout</a>";}else{?><a href="user_register.php"><img src="images/register.gif" alt="" width="89" height="24" border="0" /></a><?php } ?></td>
                              </tr>
                          </table></td>
                        </tr>
                    </table></td>
                  </tr>
              </table></td>
            </tr>
            <tr>
              <td height="22">&nbsp;</td>
            </tr>
            <tr>
              <td><table width="963" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td width="166" align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td align="left" valign="top"><img src="images/quick-links.gif" alt="" width="166" height="33" /></td>
                        </tr>
                        <tr>
                          <td height="16"></td>
                        </tr>
						<tr align="left" valign="top">
                          <td style="border:#0E4273 1px solid;"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                              <tr>
                                <td height="21" bgcolor="#CFDDEA" class="search" style="border-bottom:#0E4273 1px solid; padding-left:24px;">Gear Corner</td>
                              </tr>
                              <tr>
                                <td height="21" class="leftmenutext" style="border-bottom:#0E4273 1px solid;padding-left:24px;"><a href="#?sport_id=<?=base64_encode("58")?>">Swimming</a></td>
                              </tr>
							  <tr>
                                <td height="21" class="leftmenutext" style="border-bottom:#0E4273 1px solid;padding-left:24px;"><a href="#?sport_id=<?=base64_encode("59")?>">Running</a></td>
                              </tr>
							  <tr>
                                <td height="21" class="leftmenutext" style="border-bottom:#0E4273 1px solid;padding-left:24px;"><a href="#?sport_id=<?=base64_encode("19")?>">Cycling</a></td>
                              </tr>
							  <tr>
                                <td height="21" class="leftmenutext" style="border-bottom:#0E4273 1px solid;padding-left:24px;"><a href="#?sport_id=<?=base64_encode("60")?>">Triathlon</a></td>
                              </tr>
							  <tr>
                                <td height="21" class="leftmenutext" style="border-bottom:#0E4273 1px solid;padding-left:24px;"><a href="#?sport_id=<?=base64_encode("71")?>">Gym / Fitness</a></td>
                              </tr>
							  <tr>
                                <td height="21" class="leftmenutext" style="border-bottom:#0E4273 1px solid;padding-left:24px;"><a href="#?sport_id=<?=base64_encode("74")?>">Outdoors</a></td>
                              </tr>
							  <tr>
                                <td height="21" class="leftmenutext" style="border-bottom:#0E4273 1px solid;padding-left:24px;"><a href="#?sport_id=<?=base64_encode("78")?>">Nutrition</a></td>
                              </tr>
							  <tr>
                                <td height="21" class="leftmenutext" style="border-bottom:#0E4273 1px solid;padding-left:24px;"><a href="#?sport_id=<?=base64_encode("72")?>">Yoga & Pilates</a></td>
                              </tr>
							  <tr>
                                <td height="21" class="leftmenutext" style="border-bottom:#0E4273 1px solid;padding-left:24px;"><a href="#?sport_id=<?=base64_encode("73")?>">Injury / Rehab</a></td>
                              </tr>
                          </table></td>
                        </tr>
						<tr>
                          <td height="16"></td>
                        </tr>
                        <tr align="left" valign="top">
                          <td style="border:#0E4273 1px solid;"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                              <tr>
                                <td height="21" bgcolor="#CFDDEA" class="search" style="border-bottom:#0E4273 1px solid; padding-left:24px;">Register Online</td>
                              </tr>
							  <tr>
                                <td height="21" class="leftmenutext" style="border-bottom:#0E4273 1px solid;padding-left:24px;"><a href="sports.php?sport_id=<?=base64_encode("58")?>">Swimming</a></td>
                              </tr>
							  <tr>
                                <td height="21" class="leftmenutext" style="border-bottom:#0E4273 1px solid;padding-left:24px;"><a href="sports.php?sport_id=<?=base64_encode("19")?>">Cycling</a></td>
                              </tr>
							  <tr>
                                <td height="21" class="leftmenutext" style="border-bottom:#0E4273 1px solid;padding-left:24px;"><a href="sports.php?sport_id=<?=base64_encode("59")?>">Running</a></td>
                              </tr>
							  <tr>
                                <td height="21" class="leftmenutext" style="border-bottom:#0E4273 1px solid;padding-left:24px;"><a href="sports.php?sport_id=<?=base64_encode("60")?>">Triathlon</a></td>
                              </tr>
							  <tr>
                                <td height="21" class="leftmenutext" style="border-bottom:#0E4273 1px solid;padding-left:24px;"><a href="sports.php?sport_id=<?=base64_encode("62")?>">Rugby</a></td>
                              </tr>
							  <tr>
                                <td height="21" class="leftmenutext" style="border-bottom:#0E4273 1px solid;padding-left:24px;"><a href="sports.php?sport_id=<?=base64_encode("61")?>">GAA</a></td>
                              </tr>
							  <tr>
                                <td height="21" class="leftmenutext" style="border-bottom:#0E4273 1px solid;padding-left:24px;"><a href="sports.php?sport_id=<?=base64_encode("2")?>">Adventure Racing</a></td>
                              </tr>
							  <tr>
                                <td height="21" class="more" style="padding-left:24px;"><a href="all_sports.php">More Links...</a></td>
                              </tr>
                          </table></td>
                        </tr>
                        <tr>
                          <td height="16">&nbsp;</td>
                        </tr>
						<tr>
							<td style="border:#0E4273 1px solid;"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                              <tr>
                                <td height="22" bgcolor="#CFDDEA" class="search" style="border-bottom:#0E4273 1px solid; padding-left:24px;">Interactive Box</td>
                              </tr>
                              <tr>
                                <td height="21" class="leftmenutext" style="border-bottom:#0E4273 1px solid;padding-left:24px;"><a href="#">Training Logs</a></td>
                              </tr>
                              <tr>
                                <td height="21" class="leftmenutext" style="border-bottom:#0E4273 1px solid;padding-left:24px;"><a href="result.php">Race Results</a></td>
                              </tr>
                              <tr>
                                <td height="21" class="leftmenutext" style="border-bottom:#0E4273 1px solid;padding-left:24px;"><a href="#">Videos</a></td>
                              </tr>
                              <tr>
                                <td height="21" class="leftmenutext" style="border-bottom:#0E4273 1px solid;padding-left:24px;"><a href="#">Chat Boards</a></td>
                              </tr>
                              <tr>
                                <td height="21" class="leftmenutext" style="border-bottom:#0E4273 1px solid;padding-left:24px;"><a href="#">Blogs</a></td>
                              </tr>
                              <tr>
                                <td height="21" class="leftmenutext" style="border-bottom:#0E4273 1px solid;padding-left:24px;"><a href="newsletter.php">Newsletters</a></td>
                              </tr>
                              <tr>
                                <td height="21" class="leftmenutext" style="border-bottom:#0E4273 1px solid;padding-left:24px;"><a href="#">Calculators</a></td>
                              </tr>
                          </table></td>
						</tr>
						<tr>
							<td height="16">&nbsp;</td>
						</tr>
						<tr>
							<td height="16" style="border:#0E4273 1px solid;"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                              <tr>
                                <td height="21" bgcolor="#CFDDEA" class="search" style="border-bottom:#0E4273 1px solid; padding-left:24px;">Links</td>
                              </tr>
                              <tr>
                                <td height="21" class="leftmenutext" style="border-bottom:#0E4273 1px solid;padding-left:24px;"><a href="#">special advertiser1</a></td>
                              </tr>
                              <tr>
                                <td height="21" class="leftmenutext" style="border-bottom:#0E4273 1px solid;padding-left:24px;"><a href="#">special advertiser2</a></td>
                              </tr>
                              <tr>
                                <td height="21" class="leftmenutext" style="border-bottom:#0E4273 1px solid;padding-left:24px;"><a href="#">special advertiser3</a></td>
                              </tr>
                              <tr>
                                <td height="21" class="more" style="padding-left:24px;"><a href="#">More Links...</a></td>
                              </tr>
                          </table></td>
						</tr>
                    </table></td>
                    <td width="22">&nbsp;</td>
                    <td width="494" align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td valign="top" style="border:#B5B6B8 1px solid"><form action="user_register.php" method="post" enctype="multipart/form-data" name="user_registration"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                              <tr>
                                <td height="34" align="center" background="images/centerbox-topb.gif" style="background-position:left; background-repeat:repeat-x"><table width="98%" border="0" cellspacing="0" cellpadding="0">
                                  <tr>
                                    <td width="100%" align="left" class="head1">Registration</td>
                                  </tr>
                                </table></td>
                              </tr>
                              <tr>
                                <td align="left" valign="top" background="images/registrationbg.gif" style=" background-position:bottom; background-repeat:repeat-x; padding:10px;"><table width="100%" border="0" cellspacing="4" cellpadding="0">
								 <tr>
                                      <td colspan="2" align="left" class="main_txet"><strong><?php if($error){ echo "<font color='red'>".$error."</font>"; }else if($error1){ echo "<font color='red'>".$error1."</font>"; }else if($error2){ echo "<font color='red'>".$error2."</font>"; }else if($error3){ echo "<font color='red'>".$error3."</font>"; }else if($error4){ echo "<font color='red'>".$error4."</font>"; }else if($error5){ echo "<font color='red'>".$error5."</font>"; }else if($error6){ echo "<font color='red'>".$error6."</font>"; }else if($error7){ echo "<font color='red'>".$error7."</font>"; } ?></strong></td>
                                      </tr>
                                    <tr>
                                      <td width="158" align="left" valign="top" class="main_txet">First Name:</td>
                                      <td width="293" align="left" valign="top">                                        <input type="text" name="fname" id="fname" value="<?=$_POST['fname']?>" class="input" /></td>
                                    </tr>
									<tr>
                                      <td align="left" valign="top" class="main_txet">Last Name:</td>
                                      <td width="293" align="left" valign="top">                                        <input type="text" name="lname" id="lname" value="<?=$_POST['lname']?>" class="input" /></td>
                                    </tr>
                                    <tr>
                                      <td height="17" align="left" class="main_txet" >Email Address:</td>
                                      <td align="left" valign="top"><input name="email_address" type="text" id="email_address" class="input" value="<?=$_POST['email_address']?>" />&nbsp;&nbsp;<a href="javascript:CheckEmail();" class="links">Available</a><div id="div_check_email" class="main_txet"></div></td>
                                    </tr>
									<tr>
                                      <td height="17" align="left" class="main_txet"  >Confirm Email Address:</td>
                                      <td align="left" valign="top"><input name="confirm_email" type="text" id="confirm_email" class="input" value="<?=$_POST['confirm_email']?>" onchange="return check();" /></td>
                                    </tr>
									 <tr>
                                      <td align="left" valign="top" class="main_txet">Password:</td>
                                      <td align="left" valign="top"><input name="password" id="password" type="password" class="input" value="<?=$_POST['password']?>" /></td>
                                    </tr>
                                    <tr>
                                      <td align="left" valign="top" class="main_txet">Confirm Password:</td>
                                      <td align="left" valign="top"><input name="confirm_password"  id="confirm_password" type="password" class="input" value="<?=$_POST['confirm_password']?>" onchange="return check();" /></td>
                                    </tr>
                                    <tr>
                                      <td align="left" valign="top" class="main_txet">Display Name:</td>
                                      <td align="left" valign="top"><input name="display_name" id="display_name" type="text" class="input" value="<?=$_POST['display_name']?>" />&nbsp;&nbsp;<a href="javascript:CheckName();" class="links">Available</a><div id="div_check_name" class="main_txet"></div></td>
                                    </tr>
                                    <tr>
                                      <td align="left" valign="top" class="main_txet">Gender:</td>
                                      <td align="left" valign="top" class="main_txet"><input type="radio" name="sex[]" value="male" <?php if($_POST['sex'][0] == 'male'){ print "checked='checkded'"; } ?> />Male&nbsp;&nbsp;<input type="radio" name="sex[]" value="female" <?php if($_POST['sex'][0] == 'female'){ print "checked='checkded'"; } ?> />Female</td>
                                    </tr>
									 <tr>
                                  <td align="left" valign="top" class="main_txet">Date of birth:</td>
                                  <td align="left" valign="top"><select name="month" id="month">
                                    <option value="01" <?php if($_POST['month'] == "01"){echo "selected='selected'";}else if(date("M") == "01"){echo "selected='selected'";}?>>Jan</option>
                                    <option value="02" <?php if($_POST['month'] == "02"){echo "selected='selected'";}else if(date("M") == "02"){echo "selected='selected'";}?>>Feb</option>
                                    <option value="03" <?php if($_POST['month'] == "03"){echo "selected='selected'";}else if(date("M") == "03"){echo "selected='selected'";}?>>Mar</option>
                                    <option value="04" <?php if($_POST['month'] == "04"){echo "selected='selected'";}else if(date("M") == "04"){echo "selected='selected'";}?>>Apr</option>
                                    <option value="05" <?php if($_POST['month'] == "05"){echo "selected='selected'";}else if(date("M") == "05"){echo "selected='selected'";}?>>May</option>
                                    <option value="06" <?php if($_POST['month'] == "06"){echo "selected='selected'";}else if(date("M") == "06"){echo "selected='selected'";}?>>Jun</option>
                                    <option value="07" <?php if($_POST['month'] == "07"){echo "selected='selected'";}else if(date("M") == "07"){echo "selected='selected'";}?>>Jul</option>
                                    <option value="08" <?php if($_POST['month'] == "08"){echo "selected='selected'";}else if(date("M") == "08"){echo "selected='selected'";}?>>Aug</option>
                                    <option value="09" <?php if($_POST['month'] == "09"){echo "selected='selected'";}else if(date("M") == "09"){echo "selected='selected'";}?>>Sep</option>
                                    <option value="10" <?php if($_POST['month'] == "10"){echo "selected='selected'";}else if(date("M") == "10"){echo "selected='selected'";}?>>Oct</option>
                                    <option value="11" <?php if($_POST['month'] == "11"){echo "selected='selected'";}else if(date("M") == "11"){echo "selected='selected'";}?>>Nov</option>
                                    <option value="12" <?php if($_POST['month'] == "12"){echo "selected='selected'";}else if(date("M") == "12"){echo "selected='selected'";}?>>Dec</option>
                                  </select>
                                    &nbsp;
			<select name="day" id="day">
			<?php
			for($i=1; $i<=31; $i++){
				$selected = " ";
				if($_POST['day'] == $i){
					$selected = "selected = 'selected'";
				}else if(date("d") == $i){
					$selected = "selected = 'selected'";
				}
				if ($i<=9){
					echo "<option value='0$i' $selected>0$i</option>";
				}else{
					echo "<option value='$i' $selected>$i</option>";
				}
			}
			?>
			</select>&nbsp;
			<select name="year" id="year">
			<?php
				$target_year = date("Y");
				for($year = 1900; $year <= $target_year; $year++){
			?>
				<option value="<?=$year?>" <?php if($_POST['year'] == $year){echo "selected='selected'";}else if(date("Y") == $year){echo "selected='selected'";}?>><?=$year?></option>
			<?php } ?>
			</select></td>
            </tr>
			<tr>
                 <td align="left" valign="top" class="main_txet">Upload Picture</td>
                 <td align="left" valign="top" class="main_txet"><input type="file" name="user_pic" value="<?=$_POST['user_pic']?>" /></td>
            </tr>
            <tr>
                 <td align="left" valign="top" class="main_txet">Country:</td>
                 <td align="left" valign="top"><span class="main_txet">
                <select name="country_id" id="country_id" onChange="SelectStateFunction();" class="listbox">
					<option value="0">Select Country</option>
					<?php
						for($i=0; $i < count($country_array); $i++){
					?>
					<option value="<?=$country_array[$i]['country_id']?>" <?php if($country_array[$i]['country_id'] == $_POST['country_id']){echo "selected='selected'";}?>><?=$country_array[$i]['country_name']?>
					</option>
					<?php } ?>
					</select>
                    </span></td>
              </tr>
			  <tr>
                    <td align="left" valign="top" class="main_txet">State:</td>
                    <td align="left" valign="top">
				    <span id="div_state_list" class="main_txet">
                    <select name="state_id" id="state_id" class="listbox">
					<option value="0">Select State</option>
					<?php
						if($_POST['state_id']){
							for($i=0; $i<count($state_array); $i++){
					?>
					<option value="<?=$state_array[$i]['state_id']?>" <?php if($state_array[$i]['state_id'] == $_POST['state_id']){ print "selected='selected'";} ?>><?=$state_array[$i]['state_name']?></option>
					<?php } } ?>
 					</select>
                    </span></td>
              </tr>
              <tr>
                   <td align="left" valign="top" class="main_txet">Zip Code:</td>
                   <td align="left" valign="top"><input name="zip_code" type="text" class="input" style="width:75px;" value="<?=$_POST['zip_code']?>" /></td>
              </tr>
			  <tr>
                   <td align="left" valign="top" class="main_txet">Activity:</td>
                   <td align="left" valign="top" class="main_txet"><table width="100%">
			<tr>
	<?php
		$count = 0;
		for($i=0; $i < count($activity_array); $i++){
			if($count++%3 == 0){
				print "<tr>";
			}
	?>
	    	<td><input type="checkbox" name="activity[]" value="<?=$activity_array[$i]['activity_id']?>" <?php if($_POST['activity']){ if(in_array($activity_array[$i]['activity_id'], $_POST['activity'])){ echo "checked='checked'"; } } ?> /><?=$activity_array[$i]['activity_name']?>
	<?php } ?></td>
		</tr>
	</table></td>
			</tr>
			<tr>
			  <td align="left" valign="top" class="main_txet">&nbsp;</td>
			  <td align="left" valign="top" class="main_txet">&nbsp;</td>
			</tr>
			<tr>
			  <td align="left" valign="top" class="main_txet">Describe Yourself :</td>
			  <td align="left" valign="top" class="main_txet"><table width="100%">
	<tr>
	<?php
		$count = 0;
		for($i=0; $i < count($descp_array); $i++){
			if($count++%1 == 0){
				print "<tr>";
			}
	?>
			<td><input type="checkbox" name="describe[]" value="<?=$descp_array[$i]['describe_id']?>" <?php if($_POST['describe']){ if(in_array($descp_array[$i]['describe_id'], $_POST['describe'])){ echo "checked='checked'"; } } ?> /><?=$descp_array[$i]['describe_value']?>
			<?php } ?></td>
		</tr>
	</table></td>
                                    </tr>
									<tr>
                                      <td align="left" valign="top" class="main_txet">&nbsp;</td>
                                      <td align="left" valign="top" class="main_txet">&nbsp;</td>
                                    </tr>
									<tr>
                                      <td align="left" valign="top" class="main_txet">Special Offer</td>
                                      <td align="left" valign="top" class="main_txet"><input name="newsletter" type="checkbox" <?php if($_POST['newsletter'] != NULL){ print "checked='checked'"; } ?> />To receive Newsletter, Check This</td>
                                    </tr>
									<tr>
                                      <td align="left" valign="top" class="main_txet">&nbsp;</td>
                                      <td align="left" valign="top" class="main_txet">&nbsp;</td>
                                    </tr>
									<tr>
                                      <td align="left" valign="top" class="main_txet">&nbsp;</td>
                                      <td align="left" valign="top" class="main_txet"><img id="captcha" src="visual/visual.php" alt="" title="Cant read the numbers? Move the mouse over the speaker and listen..." style="border: 1px solid #000000" /><br /><input type="text" maxlength="5" name="code" id="code" />Enter given code here</td>
									  
                                    </tr>
									<tr>
                                      <td align="left" valign="top" class="main_txet">&nbsp;</td>
                                      <td align="left" valign="top" class="main_txet"><input type="text" maxlength="5" name="code" id="code" />Enter given code here</td>
									  
                                    </tr>
									
                                    <tr>
                                      <td align="left" valign="top" class="main_txet">Term And Conditions </td>
                                      <td align="left" valign="top" class="main_txet">
          <input type="checkbox" name="condition" id="condition" <?php if($_POST['condition'] != NULL){ print "checkded=''checked'"; } ?> />
          <span class="top-text-l">I agree to the</span> <span class="inner-blue"><a href="term_cond.php" target="_blank">Terms and Conditions</a></span> of IrishFit.com</td>
                                    </tr>
                                    <tr>
                                      <td colspan="2" align="left" valign="top" class="main_txet">&nbsp;</td>
                                      </tr>
                                    <tr>
                                      <td align="left" valign="top" class="main_txet">&nbsp;</td>
                                      <td align="left" valign="top"><input type="image" src="images/register.gif" name="user_registration" value="Submit" onclick="return check();" /></td>
                                    </tr>
                                </table></td>
                              </tr>
                          </table></form></td>
                        </tr>
                    </table></td>
                    <td width="22">&nbsp;</td>
                    <td width="259" align="center" valign="top"><table width="269" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td height="118" align="left" valign="top" background="images/right-top-banner.gif" style="background-position:top; background-repeat:no-repeat; padding-left:15px;"><table width="78%" border="0" cellspacing="0" cellpadding="0">
                              <tr>
                                <td height="15"></td>
                              </tr>
                              <tr>
                                <td align="center" valign="top" class="rightheading">Event Directors &amp; Organizers </td>
                              </tr>
                              <tr>
                                <td class="rightlink"><a href="active_giving.php">Admin Logins &raquo;</a><br />
                                  <a href="events/em_user_reg_start.php">Post an Activity &raquo;</a></td>
                              </tr>
                          </table></td>
                        </tr>
                        <tr>
                          <td>&nbsp;</td>
                        </tr>
						<tr>
                          <td align="center" valign="top"><span class="subhead1"> Event Calendar</span><br />
						  <?php
						  // Here We are defining our calender
						  // All the links are coming from calss_calender.php
						  // for further change in links go to the class_calendar.php
						  // If no month/year set, use current month/year
						  $d = getdate(time());
						  if($months == ""){
						  	$months = $d["mon"];
						  }
						  if($years == ""){
						  	$years = $d["year"];
						  }
						  
						  if(isset($_REQUEST['month']) and isset($_REQUEST['year'])){
						  		echo $cal->getMonthView($_REQUEST['month'], $_REQUEST['year']);
						  }else{
						  		echo $cal->getMonthView($months, $years);
						  }
						  ?></td>
                        </tr>
						<tr>
                          <td align="center">&nbsp;</td>
                        </tr>
                        <tr>
                          <td align="center" valign="top" style="padding:10px"><table width="120" height="600" border="0" cellpadding="0" cellspacing="0" style="border:1px solid #EAEAEA">
                            <tr>
                              <td align="center" valign="top"><?php
							  	if($ads_right_array[0]['ads_status'] == 1){
								?>
								<a href="ads_counter.php?ads_id=<?=base64_encode($ads_right_array[0]['ads_id'])?>"><img src="pictures/ads/<?=$ads_right_array[0]['ads_type']?>" width="120" height="600" border="0" /></a>
								<?php
									}else if($ads_right_array[0]['ads_status'] == 0){
										print $ads_code_array[0]['ads_type'];
									}else{
										print "Ads Here";
									} ?></td>
                            </tr>
                          </table></td>
                        </tr>
						<tr>
                          <td height="17" align="center"><a href="newsletter.php"><img src="images/right-banner2.gif" border="0" /></a></td>
                        </tr>
                    </table></td>
                  </tr>
              </table></td>
            </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td height="22" align="center" style="padding:15px;"><table width="468" height="68" border="0" cellpadding="0" cellspacing="0" style="border:1px solid #EAEAEA">
        <tr>
          <td align="left" valign="middle"><?php
							  		if($ads_bottom_array[0]['ads_status'] == 1){
								?><a href="ads_counter.php?ads_id=<?=base64_encode($ads_bottom_array[0]['ads_id'])?>"><img src="pictures/ads/<?=$ads_bottom_array[0]['ads_type']?>" width="468" height="68" border="0" /></a>
								<?php
									}else if($ads_bottom_array[0]['ads_status'] == 0){
										print $ads_bottom_array[0]['ads_type'];
								}else{ print "Ads Here"; }?></td>
        </tr>
      </table></td>
  </tr>
  <tr>
    <td height="33" align="center" background="images/footer-bg.gif"><table width="97%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="28%" align="left" class="footer">Copyright &copy; 2008 The IrishFit
 Network </td>
        <td width="72%" align="left" class="footer"><a href="term_cond.php" target="_blank">Terms of Use</a>    <a href="#">Privacy Policy</a>    <a href="#">Security</a>    <a href="#">Advertising</a>    <a href="#">Careers</a></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td align="center"><table width="97%" border="0" cellspacing="4" cellpadding="1">
      <tr>
        <td width="11%" align="left" class="footer"><strong>Organizations:</strong></td>
        <td width="89%" align="left" class="footer"><a href="#">Events</a>    <a href="#">Government</a>    <a href="#">Recreation</a>    <a href="#">Camps</a>    <a href="#">Endurance</a>    <a href="<?=PATH_WEB?>all_sports.php">Sports</a>    <a href="#">Golf</a>    <a href="#">Schools</a>    <a href="<?=PATH_WEB?>active_giving.php">Giving</a></td>
      </tr>
      <tr>
        <td align="left" class="footer"><strong>Marketers: </strong></td>
        <td align="left" class="footer"> <a href="<?=PATH_WEB?>">IrishFit</a> <a href="#">Marketing</a> <a href="#">Group</a>    <a href="#">Advertise on The IrishFit Network</a></td>
      </tr>
      <tr>
        <td align="left" class="footer"><strong>Participants: </strong></td>
        <td align="left" class="footer"><a href="<?=PATH_WEB?>">IrishFit.com</a><a href="#">ActiveGolf.com</a>    <a href="#">eteamz.com</a><a href="#">ActiveEurope.com</a></td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>
<script language="javascript">
var validation  = new Validator("user_registration");

validation.addValidation("fname","req","Please enter your First Name.");
validation.addValidation("fname","alpha");
validation.addValidation("lname","req","Please enter your Last Name.");
validation.addValidation("lname","alpha");
validation.addValidation("email_address","req","Please enter your Email Address.");
validation.addValidation("email_address","email");
validation.addValidation("confirm_email","req","Please enter your Confirm Email address.");
validation.addValidation("confirm_email","email");
validation.addValidation("password","req","Please enter your password.");
validation.addValidation("password","minlen=6","Minimum length of password is 6.");
validation.addValidation("confirm_password","req","Please enter your Confirm Password.");
validation.addValidation("zip_code","req","Please enter zip code.");
validation.addValidation("zip_code","numeric");
validation.addValidation("display_name","req","Please enter name for Display.");
validation.addValidation("country_id","dontselect=0", "Please select country name.");
validation.addValidation("code","req","Please enter security code.");
validation.addValidation("condition","shouldselchk","Plese check Terms and Conditions, if you are agree.");

</script>
<script language="javascript">
var validation  = new Validator("search_event");

validation.addValidation("search","req","Please enter event name.");

</script>